package com.sqsf.util;

import Mapper.UserMapper;
import com.sqsf.javabean.User;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class UserMapperTest {
    SqlSession session;
    UserMapper mapper;

    @Before
    public void before() {
        SqlSessionFactory factory = MyBatisUtil.getSqlSessionFactory();
        session = factory.openSession(true);
        mapper = session.getMapper(UserMapper.class);

    }

    @After
    public void after() {
        session.close();
    }

    @Test
    public void selectAll(){
        for (User user : mapper.selectAll()) {
            System.out.println(user);
        }
    }
    @Test
    public void selectByUser(){
        User u=new User();
        for (User user : mapper.selectByUser(u)) {
            System.out.println(user);
        }
    }

    @Test
    public void selectByUserOne(){
        User u=new User();
        for (User user : mapper.selectByUserOne(u)) {
            System.out.println(user);
        }
    }

    @Test
    public void trimTest(){
        mapper.trimTest();
    }
    @Test
    public void deleteByArray(){
        int[] ids={4,5,6,7,8,9,10,11,12,13,14};
        mapper.deleteByArray(ids);
    }

}